<?php

use think\migration\Seeder;

class LawsuitLegalOrderSeeder extends Seeder
{
    /**
     * Run Method.
     *
     * Write your database seeder using this method.
     *
     * More information on writing seeders is available here:
     * http://docs.phinx.org/en/latest/seeding.html
     */
    /**
     * {@inheritDoc}
     */
    public function run(): void
    {
        // 创建诉讼订单测试数据
        $this->seedLawsuitOrders();
        
        // 创建法务服务订单测试数据
        $this->seedLegalServiceOrders();
    }
    
    /**
     * 初始化诉讼订单测试数据
     */
    protected function seedLawsuitOrders()
    {
        // 确保表存在
        if (!$this->hasTable('oa_crm_lawsuit_orders')) {
            $this->output->writeln('Table oa_crm_lawsuit_orders does not exist, skipping...');
            return;
        }
        
        $data = [
            [
                'order_id' => 1,
                'customer_id' => 1,
                'is_member' => 1,
                'party_type' => 1,
                'party_name' => '杭州某科技有限公司',
                'opposite_name' => '上海某贸易有限公司',
                'case_reason' => '合同纠纷',
                'case_type' => 1,
                'stage' => 1,
                'amount' => 500000.00,
                'amount_range' => 2,
                'court_name' => '杭州市西湖区人民法院',
                'agent_scope' => '一审代理',
                'cost_type' => '全风险',
                'main_requests' => '1. 请求判令被告支付欠款50万元\n2. 请求判令被告支付违约金\n3. 请求判令被告承担本案诉讼费用',
                'customer_needs' => '尽快收回欠款，减少损失',
                'project_manager' => '张三',
                'department_head' => '李四',
                'legal_manager' => '王五',
                'company_manager' => '赵六',
                'status' => 1,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s')
            ],
            [
                'order_id' => 2,
                'customer_id' => 2,
                'is_member' => 0,
                'party_type' => 2,
                'party_name' => '张三',
                'opposite_name' => '李四',
                'case_reason' => '民间借贷',
                'case_type' => 1,
                'stage' => 2,
                'amount' => 100000.00,
                'amount_range' => 1,
                'court_name' => '杭州市中级人民法院',
                'agent_scope' => '二审代理',
                'cost_type' => '半风险',
                'main_requests' => '1. 请求判令维持原判\n2. 请求判令被告承担二审诉讼费用',
                'customer_needs' => '维护自身合法权益',
                'project_manager' => '张三',
                'department_head' => '李四',
                'legal_manager' => '王五',
                'company_manager' => '赵六',
                'status' => 2,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s')
            ]
        ];
        
        $this->table('oa_crm_lawsuit_orders')->insert($data)->save();
    }
    
    /**
     * 初始化法务服务订单测试数据
     */
    protected function seedLegalServiceOrders()
    {
        // 确保表存在
        if (!$this->hasTable('oa_crm_legal_service_orders')) {
            $this->output->writeln('Table oa_crm_legal_service_orders does not exist, skipping...');
            return;
        }
        
        $data = [
            [
                'order_id' => 3,
                'customer_id' => 3,
                'service_fee' => 60000.00,
                'order_type' => 2,
                'license_type' => 1,
                'service_count' => 12,
                'contract_term' => 2,
                'service_content' => '1. 日常法律咨询服务\n2. 合同审查与修改\n3. 法律风险评估\n4. 员工法律培训',
                'legal_advisor' => '张律师',
                'contract_status' => 2,
                'business_manager' => '张三',
                'department_head' => '李四',
                'legal_manager' => '王五',
                'company_manager' => '赵六',
                'status' => 1,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s')
            ],
            [
                'order_id' => 4,
                'customer_id' => 4,
                'service_fee' => 30000.00,
                'order_type' => 1,
                'license_type' => 2,
                'service_count' => 6,
                'contract_term' => 1,
                'service_content' => '1. 合同起草与审查\n2. 知识产权保护咨询\n3. 劳动用工合规审查',
                'legal_advisor' => '李律师',
                'contract_status' => 2,
                'business_manager' => '张三',
                'department_head' => '李四',
                'legal_manager' => '王五',
                'company_manager' => '赵六',
                'status' => 1,
                'create_time' => date('Y-m-d H:i:s'),
                'update_time' => date('Y-m-d H:i:s')
            ]
        ];
        
        $this->table('oa_crm_legal_service_orders')->insert($data)->save();
    }
}